﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DimensionData
{
    public class MockDims
    {
        private static MockDims _instance;
        public static MockDims Instance
        {
            get
            {
                if(_instance == null)
                {
                    _instance = new MockDims();
                }
                return _instance;
            }
        }

        public List<DimData> DimOrgs { get; set; }
        public List<DimData> Departments { get; set; }
        public List<DimData> Subjects { get; set; }
        public List<DimData> Products { get; set; }
        public List<DimData> Gender { get; set; }
        //public List<DimData> Gender { get; set; }


        public MockDims()
        {
            DimOrgs = new List<DimData>();

            DimData root = new DimData("0001", "集团");

            DimData com01 = root.AddChild(new DimData("000101", "公司01"));
            com01.AddChild(new DimData("00010101", "部门01"));
            com01.AddChild(new DimData("00010102", "部门02"));

            DimData com02 = root.AddChild(new DimData("000102", "公司02"));
            com02.AddChild(new DimData("00010201", "部门03"));
            com02.AddChild(new DimData("00010202", "部门04"));

            root.AddChild(new DimData("000103", "公司03"));
            root.AddChild(new DimData("000104", "公司04"));

            DimOrgs.Add(root);

            ConstructSubjects();
            ConstructProjects();
            ConstructGender();
            ConstructDepartments();
        }

        private void ConstructSubjects()
        {
            Subjects = new List<DimData>();
            DimData root1 = new DimData("0001", "科目01");

            DimData com01 = root1.AddChild(new DimData("000101", "科目01"));
            DimData com02 = root1.AddChild(new DimData("000102", "科目02"));


            DimData root2 = new DimData("0002", "科目02");
            DimData com03 = root2.AddChild(new DimData("000103", "科目03"));
            DimData com04 = root2.AddChild(new DimData("000104", "科目04"));
            DimData com041 = com04.AddChild(new DimData("00010401", "科目0401"));

            DimData com05 = root2.AddChild(new DimData("000105", "科目05"));

            Subjects.Add(root1);
            Subjects.Add(root2);
        }

        private void ConstructProjects()
        {
            Products = new List<DimData>();

            DimData root = new DimData("0001", "商品大类01");

            DimData com01 = root.AddChild(new DimData("000101", "商品01"));
            DimData com02 = root.AddChild(new DimData("000102", "商品02"));


            DimData root2 = new DimData("0002", "商品大类02");
            DimData com03 = root.AddChild(new DimData("000103", "商品03"));
            DimData com04 = root.AddChild(new DimData("000104", "商品04"));
            DimData com05 = root.AddChild(new DimData("000105", "商品05"));

            Products.Add(root);
            Products.Add(root2);
        }

        private void ConstructDepartments()
        {
            Departments = new List<DimData>();
            Departments.Add(new DimData("01", "部门A"));
            Departments.Add(new DimData("02", "部门B"));
            Departments.Add(new DimData("03", "部门C"));
        }

        private void ConstructGender()
        {
            Gender = new List<DimData>();

            DimData male = new DimData("01", "男");
            DimData female = new DimData("02", "女");

            Gender.Add(male);
            Gender.Add(female);
        }

    }
}
